package dao.workdao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import util.SHAUtil;
import dao.basedao.DBManager;

public class querysubmitDaoImpl implements querysubmitDao{

	@Override
	public int queryStudentCount(String schoolyear) throws Exception {
	    int count=0;
		Connection con=DBManager.getConn();
		PreparedStatement ps=con.prepareStatement("SELECT * from user_info where schoolyear=? and role_id=2");
        ps.setString(1,schoolyear);
        ResultSet rs=ps.executeQuery();
        while(rs.next()){
        	count++;
        }
		rs.close();
		ps.close();
		DBManager.closeConn(con);
		return count;
	}

	@Override
	public int querysubmitted(int work_id) throws Exception {
		int count=0;
		Connection con=DBManager.getConn();
		PreparedStatement ps=con.prepareStatement("SELECT * from submitwork where work_id=?");
        ps.setInt(1,work_id);
        ResultSet rs=ps.executeQuery();
        while(rs.next()){
        	count++;
        }
		rs.close();
		ps.close();
		DBManager.closeConn(con);
		return count;
	}

}
